/*
 * @Author       : Bing Chen chenbing@iocharger.com
 * @Date         : 2024-06-05 09:21:10
 * @LastEditors  : Bing Chen chenbing@iocharger.com
 * @LastEditTime : 2025-03-15 12:58:33
 * @FilePath     : \openchaoji-corelib\shared\include\OpenChaoJi_def_gbt27930_a.h
 * @Description  : 本文件定义27930规定的A类系统的所有报文格式标识超时和模块状态定义等
 *
 * Copyright (c) 2025 OpenChaoJi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the icense for the specific language governing permissions and
 * limitations under the License.
 *
 */


#ifndef __OPEN_CHAOJI_DEF_GBT27930_A_H__
#define __OPEN_CHAOJI_DEF_GBT27930_A_H__

#include "OpenChaoJi_config.h"
#include "OpenChaoJi_type.h"

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_A == CONFIG_YES)

/********************************** A类系统SECC的模块和状态ID  **********************************/

/* 空闲 */
enum OpenChaoJi_gbt27930_a_secc_stauts_idle {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_IDLE_S0_IDLE = 0,

    OPENCHAOJI_GBT27930_A_SECC_STATUS_IDLE_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_IDLE_S0_IDLE               OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_IDLE, OPENCHAOJI_GBT27930_A_SECC_STATUS_IDLE_S0_IDLE)

/* trigger */
enum OpenChaoJi_gbt27930_a_secc_stauts_trigger {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S0_CONNECT_CONFIRM = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S1_LOCK_CONFIRM,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S2_AUX_CONFIRM,

    OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_TRIGGER_S0_CONNECT_CONFIRM     OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_TRIGGER, OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S0_CONNECT_CONFIRM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_TRIGGER_S1_LOCK_CONFIRM        OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_TRIGGER, OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S1_LOCK_CONFIRM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_TRIGGER_S2_AUX_CONFIRM         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_TRIGGER, OPENCHAOJI_GBT27930_A_SECC_STATUS_TRIGGER_S2_AUX_CONFIRM)


/* 充电握手 */
enum OpenChaoJi_gbt27930_a_secc_stauts_id_handshake {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S1_WAIT_BHM,            /* 等待车辆握手 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S2_SELFCHECK,           /* 充电机自检 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S3_WAIT_BRM,            /* 等待车辆辨识 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S4_SUCCEED,             /* 成功 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S5_FAULT,               /* 故障 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S6_ERROR,               /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S0_INIT          OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S0_INIT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S1_WAIT_BHM      OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S1_WAIT_BHM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S2_SELFCHECK     OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S2_SELFCHECK)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S3_WAIT_BRM      OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S3_WAIT_BRM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S4_SUCCEED       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S4_SUCCEED)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S5_FAULT         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S5_FAULT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_HANDSHAKE_S6_ERROR         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_SECC_STATUS_HANDSHAKE_S6_ERROR)

/* 参数配置 */
enum OpenChaoJi_gbt27930_a_secc_stauts_id_config {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S1_WAIT_BCP,               /* 等待车辆参数 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S2_CHECK_PARAM,            /* 充电参数配置 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S3_WAIT_BRO,               /* 等待车辆就绪报文 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S4_RECHECK_PARAM,          /* 充电参数二次确认 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S5_EV_READY,               /* 车辆已就绪 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S6_PRE_CHARGE,             /* 等待充电机就绪(预充) */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S7_SUCCEED,                /* 成功 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S8_FAULT,                  /* 故障 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S9_ERROR,                  /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S0_INIT             OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S0_INIT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S1_WAIT_BCP         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S1_WAIT_BCP)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S2_CHECK_PARAM      OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S2_CHECK_PARAM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S3_WAIT_BRO         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S3_WAIT_BRO)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S4_RECHECK_PARAM    OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S4_RECHECK_PARAM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S5_EV_READY         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S5_EV_READY)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S6_PRE_CHARGE       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S6_PRE_CHARGE)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S7_SUCCEED          OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S7_SUCCEED)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S8_FAULT            OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S8_FAULT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CONFIG_S9_ERROR            OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_SECC_STATUS_CONFIG_S9_ERROR)

/* 充电 */
enum OpenChaoJi_gbt27930_a_secc_stauts_id_charge {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S1_WAIT_BCL,               /* 等待车辆需求 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S2_ENERGY_TRANS,           /* 能量传输 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S3_SE_SUSPEND,             /* 充电机暂停充电 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S4_EV_SUSPEND,             /* 车辆暂停充电 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S5_EV_STOP,                /* 等待车辆停机 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S6_STOPPED,                /* 停机交互完成 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S7_ERROR,                  /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S0_INIT             OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S0_INIT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S1_WAIT_BCL         OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S1_WAIT_BCL)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S2_ENERGY_TRANS     OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S2_ENERGY_TRANS)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S3_SE_SUSPEND       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S3_SE_SUSPEND)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S4_EV_SUSPEND       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S4_EV_SUSPEND)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S5_EV_STOP          OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S5_EV_STOP)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S6_STOPPED          OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S6_STOPPED)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_CHARGE_S7_ERROR            OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_SECC_STATUS_CHARGE_S7_ERROR)

/* 充电结束 */
enum OpenChaoJi_gbt27930_a_secc_stauts_end {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S1_EV_STATISTICS,             /* 车辆统计数据 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S2_SE_STATISTICS,             /* 充电机统计数据 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S3_FINISHED,                  /* 结束 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S4_ERROR,                     /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_SECC_STATUS_END_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_END_S0_INIT                OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S0_INIT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_END_S1_EV_STATISTICS       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S1_EV_STATISTICS)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_END_S2_SE_STATISTICS       OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S2_SE_STATISTICS)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_END_S3_FINISHED            OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S3_FINISHED)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_END_S4_ERROR               OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_SECC_STATUS_END_S4_ERROR)

/* 错误处理（通信超时） */
enum OpenChaoJi_gbt27930_a_secc_stauts_error {
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S1_CEM,                     /* 充电机超时处理 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S2_BEM,                     /* 车辆超时处理 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S3_CHECK,                   /* 重连判断 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S4_RETRY,                   /* 通信重连 */
    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S5_FINISHED,                /* 结束 */

    OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_NUM
};
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S0_INIT              OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S0_INIT)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S1_CEM               OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S1_CEM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S2_BEM               OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S2_BEM)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S3_CHECK             OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S3_CHECK)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S4_RETRY             OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S4_RETRY)
#define OPENCHAOJI_GBT27930_A_SECC_STATUS_ID_ERROR_S5_FINISHED          OPENCHAOJI_SECC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_SECC_STATUS_ERROR_S5_FINISHED)


/********************************** A类系统EVCC的模块和状态ID  **********************************/

/* 空闲 */
enum OpenChaoJi_gbt27930_a_evcc_stauts_idle {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_IDLE_S0_IDLE = 0,

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_IDLE_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_IDLE_S0_IDLE               OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_IDLE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_IDLE_S0_IDLE)

/* trigger */
enum OpenChaoJi_gbt27930_a_evcc_stauts_trigger {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_TRIGGER_S0_CONNECT_CONFIRM = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_TRIGGER_S1_AUX_CONFIRM,

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_TRIGGER_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_TRIGGER_S0_CONNECT_CONFIRM OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_TRIGGER, OPENCHAOJI_GBT27930_A_EVCC_STATUS_TRIGGER_S0_CONNECT_CONFIRM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_TRIGGER_S1_AUX_CONFIRM     OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_TRIGGER, OPENCHAOJI_GBT27930_A_EVCC_STATUS_TRIGGER_S1_AUX_CONFIRM)


/* 充电握手 */
enum OpenChaoJi_gbt27930_a_evcc_stauts_id_handshake {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S1_CONNECT,             /* 连接确认 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S2_WAIT_NEGO,           /* 等待握手 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S3_NEGO,                /* 握手 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S4_RECOGINZE,           /* 辨识 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S5_SUCCEED,             /* 成功 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S6_ERROR,               /* 错误-通信超时 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S7_FINISHED,            /* 结束 */

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S0_INIT          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S0_INIT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S1_CONNECT       OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S1_CONNECT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S2_WAIT_NEGO     OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S2_WAIT_NEGO)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S3_NEGO          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S3_NEGO)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S4_RECOGINZE     OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S4_RECOGINZE)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S5_SUCCEED       OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S5_SUCCEED)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S6_ERROR         OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S6_ERROR)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_HANDSHAKE_S7_FINISHED      OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_HANDSHAKE_S7_FINISHED)

/* 参数配置 */
enum OpenChaoJi_gbt27930_a_evcc_stauts_id_config {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S1_WAIT_CML,               /* 等待充电机参数 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S2_CHECK_PARAM,            /* 充电参数配置 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S3_UPDATE_PARAM,           /* 充电参数变更 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S4_WAIT_BRO,               /* 等待车辆就绪 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S5_WAIT_CRO,               /* 等待充电机就绪 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S6_SUCCEED,                /* 成功 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S7_FAULT,                  /* 故障 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S8_ERROR,                  /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S0_INIT             OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S0_INIT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S1_WAIT_CML         OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S1_WAIT_CML)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S2_CHECK_PARAM      OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S2_CHECK_PARAM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S3_UPDATE_PARAM     OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S3_UPDATE_PARAM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S4_WAIT_BRO         OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S4_WAIT_BRO)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S5_WAIT_CRO         OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S5_WAIT_CRO)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S6_SUCCEED          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S6_SUCCEED)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S7_FAULT            OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S7_FAULT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CONFIG_S8_ERROR            OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CONFIG, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CONFIG_S8_ERROR)

/* 充电 */
enum OpenChaoJi_gbt27930_a_evcc_stauts_id_charge {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S1_WAIT_CCS,               /* 等待充电机状态 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S2_ENERGY_TRANS,           /* 能量传输 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S3_SE_SUSPEND,             /* 充电机暂停充电 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S4_EV_SUSPEND,             /* 车辆暂停充电 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S5_EV_STOP,                /* 车辆主动中止充电 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S6_SE_STOP,                /* 充电机主动中止充电 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S7_STOPPED,                /* 停机交互完成 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S8_ERROR,                  /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S0_INIT             OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S0_INIT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S1_WAIT_CCS         OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S1_WAIT_CCS)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S2_ENERGY_TRANS     OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S2_ENERGY_TRANS)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S3_SE_SUSPEND       OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S3_SE_SUSPEND)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S4_EV_SUSPEND       OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S4_EV_SUSPEND)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S5_EV_STOP          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S5_EV_STOP)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S6_SE_STOP          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S6_SE_STOP)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S7_STOPPED          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S7_STOPPED)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_CHARGE_S8_ERROR            OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_CHARGE, OPENCHAOJI_GBT27930_A_EVCC_STATUS_CHARGE_S8_ERROR)

/* 充电结束 */
enum OpenChaoJi_gbt27930_a_evcc_stauts_end {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S1_STATISTICS,                /* 统计数据 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S2_FINISHED,                  /* 结束 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S3_ERROR,                     /* 错误-通信超时 */

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_END_S0_INIT                OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S0_INIT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_END_S1_STATISTICS          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S1_STATISTICS)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_END_S2_FINISHED            OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S2_FINISHED)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_END_S3_ERROR               OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_END, OPENCHAOJI_GBT27930_A_EVCC_STATUS_END_S3_ERROR)

/* 错误处理（通信超时） */
enum OpenChaoJi_gbt27930_a_evcc_stauts_error {
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S0_INIT = 0,
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S1_CEM,                     /* 充电机超时处理 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S2_BEM,                     /* 车辆超时处理 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S3_CHECK,                   /* 重连判断 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S4_WAIT_CRM,                /* 等待重连 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S5_RETRY,                   /* 通信重连 */
    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S6_FINISHED,                /* 结束 */

    OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_NUM
};
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S0_INIT              OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S0_INIT)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S1_CEM               OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S1_CEM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S2_BEM               OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S2_BEM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S3_CHECK             OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S3_CHECK)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S4_WAIT_CRM          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S4_WAIT_CRM)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S5_RETRY             OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S5_RETRY)
#define OPENCHAOJI_GBT27930_A_EVCC_STATUS_ID_ERROR_S6_FINISHED          OPENCHAOJI_EVCC_MODULE_STATUS_ID(OPENCHAOJI_GBT27930_A_MODULE_ERROR, OPENCHAOJI_GBT27930_A_EVCC_STATUS_ERROR_S6_FINISHED)

/********************************** 所有A类系统报文的统一Tag定义  **********************************/
//#define OPENCHAOJI_GBT27930_A_PID_TAG(PGN)   (((int)(PGN)) & 0xFF) /* A类系统消息均为周期发送，无需确认 */
#define OPENCHAOJI_GBT27930_A_PID_TAG(SA, PS, PF, P, ACK)   (((((uint32_t)(SA))&0xff) << 0) | \
															((((uint32_t)(PS))&0xff) << 8) | \
															((((uint32_t)(PF))&0xff) << 16) | \
															((((uint32_t)(P))&0x07) << 24) | \
															((((uint32_t)(ACK))&0x01) << 27) | \
															(((uint32_t)(OPENCHAOJI_GBT27930_SYSTEM_A_MSG))<<28))

/*  对TAG信息中的每个元素的解析定义 */
#define OPENCHAOJI_GBT27930_A_PID_TAG_OF_SA(TAG)       (((uint32_t)(TAG)) % 0x100)
#define OPENCHAOJI_GBT27930_A_PID_TAG_OF_PS(TAG)       ((((uint32_t)(TAG))>>8) % 0x100)
#define OPENCHAOJI_GBT27930_A_PID_TAG_OF_PF(TAG)       ((((uint32_t)(TAG))>>16) % 0x100)
#define OPENCHAOJI_GBT27930_A_PID_TAG_OF_P(TAG)        ((((uint32_t)(TAG))>>24) % 0x08)
#define OPENCHAOJI_GBT27930_A_PID_TAG_OF_ACK(TAG)      ((((uint32_t)(TAG))>>27) % 0x02)

#define OPENCHAOJI_GBT27930_A_PID_TAG_CHM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CHM, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BHM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BHM, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CRM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CRM, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BRM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BRM, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BCP       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BCP, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CTS       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CTS, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CML       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CML, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BRO       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BRO, 4, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CRO       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CRO, 4, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BCL       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BCL, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BCS       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BCS, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CCS       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CCS, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BSM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BSM, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BMV       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BMV, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BMT       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BMT, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BSP       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BSP, 7, OPENCHAOJI_GBT27930_MSG_TYPE_RM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BST       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BST, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CST       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CST, 4, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BSD       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BSD, 4, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CSD       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CSD, 6, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_BEM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_PGN_BEM, 2, OPENCHAOJI_GBT27930_MSG_TYPE_URM)
#define OPENCHAOJI_GBT27930_A_PID_TAG_CEM       OPENCHAOJI_GBT27930_A_PID_TAG(OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC, OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC, OPENCHAOJI_GBT27930_A_PGN_CEM, 2, OPENCHAOJI_GBT27930_MSG_TYPE_URM)


/* SECC */
/* TCP: SECC需要发送报文的周期 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCHM       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCRM       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCTS       500
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCML       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCRO       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCCS       50
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCST       10
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCSD       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCPCEM       250

/* TCO: SECC判断EVCC报文超时的时间 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBHM       10000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBRM       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBCP       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBRO       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBRO_AA    60000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBCL       1000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBCS       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBSM       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBST       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBSD       10000

#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOCSD       5000    /* 充电结束阶段, SECC退出充电前持续发送CSD报文的时间, 5s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOCEP       10000   /* 错误处理阶段, SECC等待错误处理完成的时间, 10s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCOBSUP      600000  /* 充电阶段, SECC判断EVCC暂停充电超时时间, 10min */

#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_RELAY           1000  /* SECC等待继电器动作执行的超时时间(电子锁、辅助电源、继电器, 厂商自定义), 1s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_PRECHG_EVCC_VOL 1000  /* 预充阶段, SECC延迟检测继电器外侧电压的时间(等待充电口电压稳定), 1s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_PRECHG          10000 /* SECC判断预充阶段超时时间, 10s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_VENT            1000  /* SECC等待泄放过程的超时时间, 1s */

#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_STOP_NORMAL(CUR) (((uint32_t)(CUR) >= 1000) ? (uint32_t)(CUR) : 1000) /* 正常停机, SECC不小于100A/s降电流, 电流将至5A及以下后断开C1C2, CUR 0.1A/位 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_STOP_FAULT      100   /* 非正常停机, 车辆连接异常/出现不能继续充电的故障, SECC在100ms内断开C1C2 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_STOP_ERROR      1000  /* 非正常停机, 电子锁异常/车辆接口处充电电压超过车辆最高允许充电总电压+15V, SECC在1s内断开C1C2 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_SECC_TCO_STOP_TIMEOUT    5000  /* 非正常停机, 通信超时, SECC在5s内断开C1C2 */

/* EVCC */
/* TVP: EVCC需要发送报文的周期 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBHM       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBRM       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBCP       500
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBRO       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBCL       50
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBCS       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBSM       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBMV       10000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBMT       10000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBSP       10000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBST       10
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBSD       250
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVPBEM       250

/* TVO: EVCC判断SECC报文超时的时间 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCRM_00    30000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCRM_AA    5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCML       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCRO       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCRO_AA    60000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCCS       1000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCST       5000
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCSD       10000

#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOBSLP      300000  /* 唤醒后，EVCC进入休眠的时间, 应大于5min */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCSUP      600000  /* 充电阶段, EVCC判断SECC暂停充电超时时间, 10min */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOBEP       10000   /* 错误处理阶段, EVCC等待错误处理完成的时间, 10s */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVOCRM       30000   /* 错误处理阶段, EVCC通信重连时判断CRM报文超时时间, 30s */

#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVO_STOP_NORMAL(CUR) (((uint32_t)(CUR) >= 1000) ? (uint32_t)(CUR) : 1000) /* 正常停机, SECC不小于100A/s降电流, 电流降到5A及以下后, EVCC断开C5C6, CUR 0.1A/位 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVO_STOP_FAULT      300    /* 非正常停机, 车辆连接异常/出现不能继续充电的故障, EVCC在300ms(由车辆根据故障严重程度决定)内断开C5C6 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVO_STOP_TIMEOUT    10000  /* 非正常停机, 通信超时, EVCC在10内断开C5C6 */
#define OPENCHAOJI_GBT27930_A_PID_TIMEOUT_EVCC_TVO_RELAY           1000   /* EVCC等待继电器动作执行的超时时间(厂商自定义), 1s */

/********************************** A类系统报文定义 **********************************/

/* 系统A的充电机报文定义: CHM CRM CTS CML CRO CCS CST CSD CEM: 领充 */

/*
* 充电机握手报文(CHM)
*/
struct OpenChaoJi_gbt27930_a_msg_chm {
    uint8_t     pro_version[3];     /* 充电机通信协议版本号, 本文件规定当前版本为V1.1, 表示为:byte3—00H;byte2—01H;bytel—01H */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CHM   3

/* 充电机辨识报文(CRM) */
struct OpenChaoJi_gbt27930_a_msg_crm {
	uint8_t     recognition_result; /* 辨识结果, 0x00:未辨识BMS及车辆信息；0xAA:已辨识BMS及车辆信息 */
	uint32_t    charger_id;         /* 充电机编号, 1/位, 0偏移量, 数据范围0~0xffffffff */
	uint8_t     charger_location[3];/* 充电机/充电站所在区域编码, 标准ASCII码 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CRM   8

/* 充电机发送时间同步信息报文(CTS) */
struct OpenChaoJi_gbt27930_a_msg_cts {
	uint8_t		time[7];    /* 年/月/日/时/分/秒, 压缩BCD码 如2019年10月11日15时20分13秒表示为：
                               byte7-19H, byte6-20H, byte5-10H, byte4-11H, byte3-15H, byte2-20H, byte1-13H */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CTS   7

/* 充电机最大输出能力报文(CML) */
struct OpenChaoJi_gbt27930_a_msg_cml {
	uint16_t	max_output_voltage;/* 充电机最高充电电压/V, 0.1V/位, 0V偏移量 */
	uint16_t	min_output_voltage;/* 充电机最低充电电压/V, 0.1V/位, 0V偏移量 */
	uint16_t	max_output_current;/* 充电机最大充电电流/A, 0.1A/位, -400A偏移量 */
	uint16_t	min_output_current;/* 充电机最小充电电流/A, 0.1A/位, -400A偏移量 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CML   8
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CML_VER_1_0   6

/* 充电机输出准备就绪报文(CRO) */
struct OpenChaoJi_gbt27930_a_msg_cro {
	uint8_t	    charger_ready_for_charging;/* 充电机是否充电准备好(<0x00>:=充电机未完成充电准备；
                                            <0xAA>:=充电机完成充电准备；<0xFF>:=无效) */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CRO   1

/* 充电机充电状态报文(CCS) */
struct OpenChaoJi_gbt27930_a_msg_ccs {
	uint16_t	output_voltage_value;   /* 车辆接口当前电压测量值/V, 0.1V/位, 0V偏移量 */
	uint16_t	output_current_value;   /* 车辆接口当前电流测量值/A, 0.1A/位, -400A偏移量 */
	uint16_t	cumulative_charging_time;/* 累计充电时间/min, 1min/位, 0min偏移量, 数据范围0~600min */
	union {
		uint8_t all;
		struct {
			uint8_t	    charging_permissible:2;  /* 充电允许(<00>:=暂停；<01>:=允许) */
			uint8_t	    res:6;                  /* 保留位 */
		} bits;
	} state;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CCS   7
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CCS_VER_1_0   6

/* 充电机中止充电报文(CST) */
struct OpenChaoJi_gbt27930_a_msg_cst {
	union {
		uint8_t all;
		struct {
			uint8_t	condition_reached_suspends:2;    /* 达到充电机设定的条件中止(如按金额充电、按时间充电，按 SOC 充电等) */
			uint8_t	artificial_suspends:2;  /* 人工中止(包括通信开始后由用户触发的主动中止充电) */
			uint8_t	fault_suspends:2;       /* 故障中止(包括通信开始后各类非正常中止) */
			uint8_t	bms_actively_suspends:2;/* 车辆主动中止(包括接收车辆的 BST 报文) */
		} bits;
	} stop_code; /*充电机中止充电原因 8bit */
	union {
		uint16_t all;
		struct {
			uint16_t	charger_over_temp:2;		/* 充电机过温故障 */
			uint16_t	charging_connector_fault:2;	/* 充电连接器故障 */
			uint16_t	charger_inner_part_over_temp:2;	/* 充电机内部过温故障 */
			uint16_t	can_not_supply_req_energy:2;	/* 所需电量不能传送 */
			uint16_t	emergency_stop:2;		/* 充电机急停故障 */
			uint16_t	other_fault:2;			/* 其他故障 */
			uint16_t	self_check_fault:2;	    /* 自检故障 (包括绝缘检测、短路测试、粘连检测等自检过程中出现的故障)*/
			uint16_t	precharging_fault:2;    /* 预充故障 */
		} bits;
	} fault_code; /* 充电机中止充电故障原因 16bit */
	union {
		uint8_t all;
		struct {
			uint8_t	current_mismatch_error:2;/* 电流不匹配错误 */
			uint8_t	voltage_abnormal_error:2;/* 电压异常错误 */
			uint8_t	param_mismatch_error:2;/* 参数不匹配错误 */
			uint8_t	res:2;                 /* 保留位 */
		} bits;
	} error_code; /* 充电机中止充电错误原因  8bit */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CST   4

/* 充电机统计报文(CSD) */
struct OpenChaoJi_gbt27930_a_msg_csd {
	uint16_t	cumulative_charging_time;/* 本次充电时间/min, 1min/位, 0min偏移量, 数据范围0~600min */
	uint16_t	output_energy;          /* 输出能量/kWh, 0.1kWh/位, 0kWh偏移量*/
	uint32_t	charger_id;             /* 充电机编号, 1/位, 0偏移量, 数据范围: 0~0xffffffff */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CSD   8

/* 充电机错误报文(CEM) */
struct OpenChaoJi_gbt27930_a_msg_cem {
	union {
		uint32_t		all;			/* bits (00:正常 01:超时 10:不可信状态) */
		struct {
			uint32_t	timeout_brm:2;  /* 接收BMS和车辆的辨识报文(BRM)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	rev1:6;			/* 保留位 */

			uint32_t	timeout_bcp:2;  /* 接收电池充电参数报文(BCP)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	timeout_bro:2;  /* 接收车辆完成充电准备报文(BRO)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	rev2:4;			/* 保留位 */

			uint32_t	timeout_bcs:2;  /*接收电池充电总状态报文(BCS)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	timeout_bcl:2;  /*接收电池充电需求报文(BCL)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	timeout_bst:2;  /*接收车辆中止充电报文(BST)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	rev3:2;			/* 保留位 */

			uint32_t	timeout_bsd:2;  /* 接收车辆充电统计报文(BSD)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	timeout_bsm:2;  /* 接收动力蓄电池状态信息报文(BSM)超时(00:正常 01:超时 10:不可信状态) */
			uint32_t	rev4:4;		    /* 保留位 */
		} bits;
	} tout_code;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_CEM   4


/* GBT27930_A的EVCC报文定义: BHM BRM BCP BRO BCL BCS BSM BMV BMT BSP BST BSD BEM */

/* 车辆握手报文(BHM) */
struct OpenChaoJi_gbt27930_a_msg_bhm {
    uint16_t    insul_request_voltage;          /* 车辆端绝缘监测允许总电压/V, 0.1V/位, 0V偏移量 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BHM   2

/* BMS和车辆辨识报文(BRM) */
struct OpenChaoJi_gbt27930_a_msg_brm {
    uint8_t     pro_version[3];                 /* 车辆通信协议版本号 (V1.10) */
    uint8_t     batt_type;                      /* 电池类型 01H:铅酸电池, 02H:镍氢电池, 03H:磷酸铁锂电池, 04H:锰酸锂电池, 05H:钴酸锂电池, 06H:三元材料电池, 07H:聚合物锂离子电池, 08H:钛酸锂电池, FFH:其他电池*/
    uint16_t    rated_capacity;                 /* 动力蓄电池额定容量/Ah, 0.1Ah/位, 0Ah偏移量*/
    uint16_t    rated_voltage;                  /* 动力蓄电池额定总电压/V, 0.1V/位, 0V偏移量 */
    uint8_t     batt_factory[4];                /* 电池生产厂商名称, 标准ASCII码 */
    uint8_t     batt_sn[4];                     /* 电池组序号, 厂商自定义 */
    uint8_t     batt_date_year;                 /* 电池组生产日期: 年, 1年/位, 1985年偏移量, 数据范围1985年-2235年 */
    uint8_t     batt_date_month;                /* 电池组生产日期: 月, 1月/位, 0月偏移量, 数据范围1-12月*/
    uint8_t     batt_date_day;                  /* 电池组生产日期: 日, 1日/位, 0日偏移量, 数据范围1-31日*/
    uint8_t     charge_cycles[3];               /* 电池组充电次数, 1次/位, 0次偏移量*/
    uint8_t     batt_property;                  /* 电池组产权标识, 0:租赁, 1:车自有 */
    uint8_t     res;                            /* 预留 */
    uint8_t     evin[17];                       /* 扩展车辆识别码 (EVIN), 扩展ASCII码 */
    uint8_t     sw_version[8];                  /* 车辆通信协议软件版本号, 表示当前车辆版本信息 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BRM   49
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BRM_VER_1_0   41

/* 车辆充电参数报文(BCP) */
struct OpenChaoJi_gbt27930_a_msg_bcp {
    uint16_t    allow_cellvolt;                 /* 单体蓄电池最高允许充电电压/V, 0.01V/位, 0V偏移量, 数据范围0-24V */
    uint16_t    allow_current;                  /* 最高允许充电电流/A, 0.1A/位, -400A偏移量 */
    uint16_t    rated_energy;                   /* 动力蓄电池标称总能量/kWh, 0.1kWh/位, 0kWh偏移量, 数据范围0-1000kWh */
    uint16_t    allow_voltage;                  /* 最高允许充电总电压/V, 0.1V/位, 0V偏移量 */
    uint8_t     allow_tempera;                  /* 单体蓄电池最高允许温度/℃, 1℃/位, -50℃偏移量, 数据范围-50℃~200℃ */
    uint16_t    batt_soc;                       /* 整车荷电状态, 0.1%/位, 0%偏移量, 数据范围0-100% */
    uint16_t    measured_voltage;               /* 车辆接口当前电压测量值/V, 0.1V/位, 0V偏移量 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BCP   13

/* 车辆充电准备就绪报文(BRO) */
struct OpenChaoJi_gbt27930_a_msg_bro {
    uint8_t     bms_ready;                      /* 车辆准备就绪状态 (0x00:未做好充电准备；0xAA:完成充电准备；0xFF:无效) */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BRO   1

/* 电池充电需求报文(BCL) */
struct OpenChaoJi_gbt27930_a_msg_bcl {
    uint16_t    target_voltage;                 /* 车辆接口充电电压需求/V, 0.1V/位, 0V偏移量 */
    uint16_t    target_current;                 /* 车辆接口充电电流需求/A, 0.1A/位, -400A偏移量 */
    uint8_t     charge_mode;                    /* 充电模式, 0x01:恒压充电, 0x02:恒流充电 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BCL   5

/* 电池充电总状态报文(BCS) */
struct OpenChaoJi_gbt27930_a_msg_bcs {
    uint16_t    measured_voltage;               /* 车辆接口当前电压测量值/V, 0.1V/位, 0V偏移量 */
    uint16_t    measured_current;               /* 车辆接口当前电流测量值/A, 0.1A/位, -400A偏移量 */
    union {
        uint16_t        all;
        struct {
            uint16_t    value   :12;            /* 最高单体蓄电池电压值, 0.01V/位, 0V偏移量, 数据范围0-24V */
            uint16_t    group   :4;             /* 最高单体蓄电池电压分组号, 1/位, 0偏移量, 数据范围0-15 */
        } bits;
    } max_cellvolt;                             /* 最高单体蓄电池电压及其组号 */
    uint8_t     soc;                            /* 当前荷电状态, 1%/位, 0%偏移量, 数据范围0-100%*/
    uint16_t    expected_time;                  /* 估算剩余充电时间/min, 1min/位, 0min偏移量 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BCS   9

/* 车辆状态信息报文(BSM) */
struct OpenChaoJi_gbt27930_a_msg_bsm {
    uint8_t     max_cellvolt_id;                /* 最高单体蓄电池电压所在编号, 1/位, 1偏移量, 数据范围1-256 */
    uint8_t     max_tempera;                    /* 当前单体蓄电池最高温度/℃, 1℃/位, -50℃偏移量, 数据范围-50~200℃*/
    uint8_t     max_tempera_id;                 /* 最高动力蓄电池温度检测点编号, 1/位, 1偏移量, 数据范围1-128 */
    uint8_t     min_tempera;                    /* 当前单体蓄电池最低温度/℃, 1℃/位, -50℃偏移量, 数据范围-50~200℃ */
    uint8_t     min_tempera_id;                 /* 最低动力蓄电池温度检测点编号, 1/位, 1偏移量, 数据范围1-128 */
    union {
        uint16_t        all;
        struct {
            uint16_t    warn_cellvolt   :2;     /* 单体蓄电池电压过高/过低 (00:正常 01:过高 10:过低) */
            uint16_t    warn_soc        :2;     /* 动力蓄电池荷电状态过高/过低 (00:正常 01:过高 10:过低) */
            uint16_t    warn_current    :2;     /* 动力蓄电池充电过流 (00:正常 01:过流 10:不可信状态) */
            uint16_t    warn_tempera    :2;     /* 动力蓄电池温度过高 (00:正常 01:过高 10:不可信状态) */
            uint16_t    warn_insul      :2;     /* 动力蓄电池绝缘状态 (00:正常 01:不正常 10:不可信状态) */
            uint16_t    warn_connector  :2;     /* 动力蓄电池组输出连接器连接状态 (00:正常 01:不正常 10:不可信状态) */
            uint16_t    charge_enable   :2;     /* 充电允许 (00:禁止；01:允许) */
            uint16_t    res             :2;     /* 预留 */
        } bits;
    } batt_state;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BSM   7

/* 单体蓄电池电压报文(BMV) */
struct OpenChaoJi_gbt27930_a_msg_bmv {
    union {
        uint16_t        all;
        struct {
            uint16_t    value   :12;            /* 单体蓄电池电压值/V, 0.01V/位, 0V偏移量, 数据范围0-24V */
            uint16_t    group   :4;             /* 电压分组号, 1/位, 0偏移量, 数据范围0-15 */
        } bits;
    } cellvolt[256];                            /* 单体蓄电池电压 */
    uint16_t cellvolt_num;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BMV   512
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BMV_MIN   2

/* 动力蓄电池温度报文(BMT) */
struct OpenChaoJi_gbt27930_a_msg_bmt {
    uint8_t     tempera[128];                   /* 动力蓄电池温度/℃, 1℃/位, -50℃偏移量, 数据范围-50℃~200℃ */
    uint8_t     tempera_num;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BMT   128
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BMT_MIN   1

/* 动力蓄电池预留报文(BSP) */
struct OpenChaoJi_gbt27930_a_msg_bsp {
    uint8_t     res[16];                        /* 动力蓄电池预留字段 */
    uint8_t     res_num;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BSP   16
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BSP_MIN   1

/* 车辆中止充电报文(BST) */
struct OpenChaoJi_gbt27930_a_msg_bst {
    union {
        uint8_t         all;
        struct {
            uint8_t     soc             :2;     /* 达到所需求的SOC目标值 */
            uint8_t     voltage         :2;     /* 达到总电压的设定值 */
            uint8_t     cellvolt        :2;     /* 达到单体电压的设定值 */
            uint8_t     charger         :2;     /* 充电机主动中止 */
        } bits;
    } stop_code;                                /* 车辆中止充电原因 */
    union {
        uint16_t        all;
        struct {
            uint16_t    insul           :2;     /* 绝缘故障*/
            uint16_t    inlet_tempera   :2;     /* 车辆插座过温故障 */
            uint16_t    cable_tempera   :2;     /* 车辆内部线束或相关连接器过温 */
            uint16_t    coupler         :2;     /* 充电耦合器连接故障 */
            uint16_t    batt_tempera    :2;     /* 电池组温度过高故障 */
            uint16_t    relay           :2;     /* 高压继电器故障 */
            uint16_t    cc2_volt        :2;     /* 检测点2电压检测故障 */
            uint16_t    other           :2;     /* 其他原因 */
        } bits;
    } fault_code;                               /* 车辆中止充电故障原因 */
    union {
        uint8_t         all;
        struct {
            uint8_t     current         :2;     /* 电流过大 */
            uint8_t     voltage         :2;     /* 电压异常 */
            uint8_t     param           :2;     /* 充电参数不匹配 */
            uint8_t     res             :2;     /* 预留 */
        } bits;
    } error_code;                               /* 车辆中止充电错误原因 */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BST   4

/* 车辆统计数据报文(BSD) */
struct OpenChaoJi_gbt27930_a_msg_bsd {
    uint8_t     end_soc;                        /* 中止荷电状态SOC, 1%/位, 0%偏移量, 数据范围0-100% */
    uint16_t    min_cellvolt;                   /* 单体蓄电池最低电压/V, 0.01V/位, 0V偏移量, 数据范围0-24V  */
    uint16_t    max_cellvolt;                   /* 单体蓄电池最高电压/V, 0.01V/位, 0V偏移量, 数据范围0-24V  */
    uint8_t     min_tempera;                    /* 动力蓄电池最低温度/℃, 1℃/位, -50℃偏移量, 数据范围-50℃~200℃ */
    uint8_t     max_tempera;                    /* 动力蓄电池最高温度/℃, 1℃/位, -50℃偏移量, 数据范围-50℃~200℃ */
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BSD   7

/* BMS及车辆错误报文(BEM) */
struct OpenChaoJi_gbt27930_a_msg_bem {
    union {
        uint32_t        all;                    /* bits (00:正常 01:超时 10:不可信状态) */
        struct {
            uint32_t    crm_00          :2;     /* 接收充电机辨识报文(CRM=0x00)超时 */
            uint32_t    crm_aa          :2;     /* 接收充电机辨识报文(CRM=0xAA)超时 */
            uint32_t    res1            :4;     /* 预留 */
            uint32_t    cml             :2;     /* 接收充电机时钟同步和最大输出能力报文(CML)超时 */
            uint32_t    cro             :2;     /* 接收充电机完成充电准备报文(CRO)超时 */
            uint32_t    res2            :4;     /* 预留 */
            uint32_t    ccs             :2;     /* 接收充电机充电状态报文(CCS)超时 */
            uint32_t    cst             :2;     /* 接收充电机中止充电报文(CST)超时 */
            uint32_t    res3            :4;     /* 预留 */
            uint32_t    csd             :2;     /* 接收充电机充电统计报文(CSD)超时 */
            uint32_t    res4            :6;     /* 预留 */
        } bits;
    } tout_code;
};
#define OPENCHAOJI_GBT27930_A_MSG_LEN_BEM   4

/**
 * 统一消息处理, 用于decode/encode
 */
struct OpenChaoJi_gbt27930_a_msg {

    uint8_t pid;    // pid决定消息类型, 可以不再使用额外的枚举

    union {
        struct OpenChaoJi_gbt27930_a_msg_chm chm;
        struct OpenChaoJi_gbt27930_a_msg_crm crm;
        struct OpenChaoJi_gbt27930_a_msg_cts cts;
        struct OpenChaoJi_gbt27930_a_msg_cml cml;
        struct OpenChaoJi_gbt27930_a_msg_cro cro;
        struct OpenChaoJi_gbt27930_a_msg_ccs ccs;
        struct OpenChaoJi_gbt27930_a_msg_cst cst;
        struct OpenChaoJi_gbt27930_a_msg_csd csd;
        struct OpenChaoJi_gbt27930_a_msg_cem cem;

        struct OpenChaoJi_gbt27930_a_msg_bhm bhm;
        struct OpenChaoJi_gbt27930_a_msg_brm brm;
        struct OpenChaoJi_gbt27930_a_msg_bcp bcp;
        struct OpenChaoJi_gbt27930_a_msg_bro bro;
        struct OpenChaoJi_gbt27930_a_msg_bcl bcl;
        struct OpenChaoJi_gbt27930_a_msg_bcs bcs;
        struct OpenChaoJi_gbt27930_a_msg_bsm bsm;
        struct OpenChaoJi_gbt27930_a_msg_bmv bmv;
        struct OpenChaoJi_gbt27930_a_msg_bmt bmt;
        struct OpenChaoJi_gbt27930_a_msg_bsp bsp;
        struct OpenChaoJi_gbt27930_a_msg_bst bst;
        struct OpenChaoJi_gbt27930_a_msg_bsd bsd;
        struct OpenChaoJi_gbt27930_a_msg_bem bem;
    } msg;
};

/**
 * @function OpenChaoJi_gbt27930_a_msg_len
 * @brief 获取消息长度
 * @param msg 消息结构体 (用于处理可变长度消息)
 * @return int 消息长度
 */
extern int OpenChaoJi_gbt27930_a_msg_len(struct OpenChaoJi_gbt27930_a_msg *msg);

/**
 * @function OpenChaoJi_gbt27930_a_msg_len_max
 * @brief 获取消息最大长度 (用于编码校验)
 * @param pgi 消息类型
 * @return int 消息最大长度
 */
extern int OpenChaoJi_gbt27930_a_msg_len_max(uint8_t pgi);

/**
 * @function OpenChaoJi_gbt27930_a_msg_len_min
 * @brief 获取消息最小长度 (用于解码校验)
 * @param pgi 消息类型
 * @return int 消息最小长度
 */
extern int OpenChaoJi_gbt27930_a_msg_len_min(uint8_t pgi);

/**
 * @function OpenChaoJi_gbt27930_a_msg_len_min_v1_0
 * @brief 获取消息最小长度 (协议版本号V1.0, 用于解码校验)
 * @param pgi 消息类型
 * @return int 消息最小长度
 */
extern int OpenChaoJi_gbt27930_a_msg_len_min_v1_0(uint8_t pgi);

/**
 * @function OpenChaoJi_gbt27930_a_msg_decode
 * @brief 解码
 * @param msg 消息结构体(输出)
 * @param pf 帧标识(输入)
 * @param data 数据(输入)
 * @param len 数据长度
 * @param ver 协议版本
 * @return true 成功
 */
extern bool OpenChaoJi_gbt27930_a_msg_decode(struct OpenChaoJi_gbt27930_a_msg *msg, unsigned char pf, unsigned char *data, int len, int ver);

/**
 * @function OpenChaoJi_gbt27930_a_msg_encode
 * @brief 编码
 * @param msg 消息结构体(输入)
 * @param data 数据(输出)
 * @param max_len 数据最大长度
 * @return int 实际编码数据长度, 小于0表示失败
 */
extern int OpenChaoJi_gbt27930_a_msg_encode(struct OpenChaoJi_gbt27930_a_msg *msg, unsigned char *data, int max_len);

/**
 * @function OpenChaoJi_gbt27930_a_msg_encode_data
 * @brief 编码, 并动态分配内存
 * @param msg 消息结构体(输入)
 * @param data_len 数据长度(输出)
 * @return unsigned char * 编码数据 NULL表示失败
 */
extern unsigned char * OpenChaoJi_gbt27930_a_msg_encode_data(struct OpenChaoJi_gbt27930_a_msg *msg, int * data_len);

/**
 * @function OpenChaoJi_gbt27930_a_msg_log
 * @brief 日志
 * @param msg 消息结构体
 * @return void
 */
extern void OpenChaoJi_gbt27930_a_msg_log(const struct OpenChaoJi_gbt27930_a_msg *msg);

/**
 * @function OpenChaoJi_gbt27930_a_msg_cmpcpy系列
 */
#define DECLARE_GBT27930_A_MSG_CMPCPY(TYPE_NAME) \
    extern bool OpenChaoJi_gbt27930_a_msg_cmpcpy_##TYPE_NAME(int tag, struct OpenChaoJi_gbt27930_a_msg_##TYPE_NAME *dst, const struct OpenChaoJi_gbt27930_a_msg_##TYPE_NAME *src);

DECLARE_GBT27930_A_MSG_CMPCPY(chm)
DECLARE_GBT27930_A_MSG_CMPCPY(crm)
DECLARE_GBT27930_A_MSG_CMPCPY(cts)
DECLARE_GBT27930_A_MSG_CMPCPY(cml)
DECLARE_GBT27930_A_MSG_CMPCPY(cro)
DECLARE_GBT27930_A_MSG_CMPCPY(ccs)
DECLARE_GBT27930_A_MSG_CMPCPY(cst)
DECLARE_GBT27930_A_MSG_CMPCPY(csd)
DECLARE_GBT27930_A_MSG_CMPCPY(cem)

DECLARE_GBT27930_A_MSG_CMPCPY(bhm)
DECLARE_GBT27930_A_MSG_CMPCPY(brm)
DECLARE_GBT27930_A_MSG_CMPCPY(bcp)
DECLARE_GBT27930_A_MSG_CMPCPY(bro)
DECLARE_GBT27930_A_MSG_CMPCPY(bcl)
DECLARE_GBT27930_A_MSG_CMPCPY(bcs)
DECLARE_GBT27930_A_MSG_CMPCPY(bsm)
DECLARE_GBT27930_A_MSG_CMPCPY(bmv)
DECLARE_GBT27930_A_MSG_CMPCPY(bmt)
DECLARE_GBT27930_A_MSG_CMPCPY(bsp)
DECLARE_GBT27930_A_MSG_CMPCPY(bst)
DECLARE_GBT27930_A_MSG_CMPCPY(bsd)
DECLARE_GBT27930_A_MSG_CMPCPY(bem)

#endif	// OPENCHAOJI_CONFIG_ENABLE_GBT27930_A

#endif
